﻿using System.Data;
using System.Threading;
using System.Threading.Tasks;

namespace Sgr.Domain.Uow
{
    public interface IUnitOfWorkTransactions
    {
        ///// <summary>
        ///// 是否存在活动的事务
        ///// </summary>
        //bool HasActiveTransaction { get; }

        ///// <summary>
        ///// 开始新事务
        ///// </summary>
        ///// <param name="isolationLevel">事务隔离级别</param>
        ///// <param name="cancellationToken">取消令牌</param>
        ///// <returns></returns>
        //Task BeginTransactionAsync(
        //    IsolationLevel isolationLevel = IsolationLevel.ReadCommitted,
        //    CancellationToken cancellationToken = default);

        /// <summary>
        /// 异步提交事务
        /// </summary>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        Task CommitAsync(CancellationToken cancellationToken = default);

        /// <summary>
        /// 异步回滚事务
        /// </summary>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        Task RollbackAsync(CancellationToken cancellationToken = default);
    }
}